package com.hadoop.mr;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.StringTokenizer;

public class MyMapper  extends Mapper<Object, Text, Text, IntWritable> {

    private  final static  IntWritable ONE = new IntWritable(1);
    private  Text word = new Text();

    public void map(Object key,Text value,Context context) throws IOException, InterruptedException {
        StringTokenizer itr = new StringTokenizer(value.toString());
        while (itr.hasMoreTokens()){
            word.set(itr.nextToken());
            context.write(word, ONE);
        }
    }
}
